package com.mk.wardsystemserver.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mk.wardsystemserver.pojo.Employee;
import com.mk.wardsystemserver.pojo.Medicine;
import com.mk.wardsystemserver.mapper.MedicineMapper;
import com.mk.wardsystemserver.pojo.RespBean;
import com.mk.wardsystemserver.pojo.RespPageBean;
import com.mk.wardsystemserver.service.IMedicineService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhoubin
 * @since 2022-03-24
 */
@Service
public class MedicineServiceImpl extends ServiceImpl<MedicineMapper, Medicine> implements IMedicineService {

    @Autowired
    private MedicineMapper medicineMapper;
    @Override
    public RespPageBean getMedicineByPage(Integer pageCurrent, Integer pageSize, Medicine medicine) {
        //开启分页
        Page<Medicine> page = new Page<>(pageCurrent, pageSize);
        IPage<Medicine> medicineByPage = medicineMapper.getMedicineByPage(page, medicine);
        RespPageBean respPageBean = new RespPageBean(medicineByPage.getTotal(), medicineByPage.getRecords());
        return respPageBean;
    }

    @Override
    public List<Medicine> getMedicineName() {
        return medicineMapper.getMedicineName();
    }

}
